# from nonebot import get_driver,on_command
# from nonebot.adapters import Bot, Event
# from nonebot.typing import T_State
# import none_bot_py_plugins.main
# from none_bot_py_plugins.net import bot_recv
# from none_bot_py_plugins.net.socket_main import *
# import threading
# import time
#
# driver = get_driver()
#
#
# @driver.on_bot_connect
# async def bot_connect(bot: Bot):
#     bot_recv.bot_recv_init(bot)
#
#
# @driver.on_bot_disconnect
# async def bot_disconnect(bot: Bot):
#     bot_recv.bot_recv_disconnect()
#
#
# login = on_command("登陆")
# logout = on_command("离线")
#
#
# @login.handle()
# async def user_login(bot: Bot, event: Event, state: T_State):
#     qq_id = event.get_user_id()
#     connect_type = "private"
#     conn_id = 0
#     if getattr(event, "group_id", None):
#         conn_id = getattr(event, "group_id")
#         connect_type = "group"
#     thread_loop = asyncio.new_event_loop()
#     server1 = ServerLoop(qq_id, thread_loop)
#     task_thread = TaskThread(server1)
#     task_thread.start()
#     time.sleep(1)
#     server1.run_task('connect', (connect_type, conn_id))
#
#
# @logout.handle()
# async def user_logout(bot: Bot, event: Event, state: T_State):
#     qq_id = event.get_user_id()
#     cmd_server(qq_id, "disconnect")
#     cmd_server(qq_id, "stop")
#
#
# class TaskThread(threading.Thread):
#
#     def __init__(self, server_loop):
#         super(TaskThread, self).__init__()
#         self.__server_loop = server_loop
#
#     def run(self) -> None:
#         self.__server_loop.start()
#
